var querystring = require("querystring");

function getUsers(response, postData) {
  console.log("Request handler 'getUsers' was called.");
  console.log('post Data:' + postData);

  // Retrieve
var MongoClient = require('mongodb').MongoClient;

// Connect to the db
MongoClient.connect("mongodb://admin:password@ds029817.mongolab.com:29817/trebuchet", function(err, db) {
  if(err) { return console.dir(err); }

  var collection = db.collection('Users');
  collection.find().toArray(function(err, items) {

  	response.writeHead(200, {"Content-Type": "text/plain"});
  	response.writeHead('*', "Access-Control-Allow-Origin");
  	response.end('_getUsers(\'{"Email": "' + items[0].Email + '"}\')');
	  

  });

  
});

    
}



exports.getUsers = getUsers;
